<%--
  Created by IntelliJ IDEA.
  User: 86150
  Date: 2021/7/13
  Time: 16:05
  To change this template use File | Settings | File Templates.
--%>
<<%@ page language="java" contentType="text/html; charset=UTF-8"
          pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>二维码生成</title>
    <%
        /********** 保存网站的基本路径 ***********/
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                + path + "/";
        //将该路径地址缓存到 session中 ,例如：http://localhost:8090/tjnu_ssh_1128/
        session.setAttribute("mybasePath", basePath);
    %>
    <!-- CSS -->
    <link rel="stylesheet" href="${mybasePath}assets/bootstrap/css/bootstrap.min.css">
    <jsp:include page="../include/headtag.jsp" />
    <!-- <link rel="stylesheet"
        href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500"> -->
    <link rel="stylesheet"
          href="assets/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/form-elements.css">
    <link rel="stylesheet" href="assets/css/style.css">
    <script src="${mybasePath}assets/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript">
        var dm;
        var dv;
        var dmlength;

        function enumDiv(a,b,c){
            dm=a.split(","); //字符分割
            dv=b.split(","); //字符分割
            dmlength=dm.length;
            var html="";
            for (var i = 0; i < dmlength; i++) {
                html=html+'<option value="'+dm[i]+'">'+dm[i]+'</option>';
            }
            $(eval(c)).append(html);
        }
    </script>
    <script>
        if('${qrCodePath}'){

            var img = '<img src="${mybasePath}${qrCodePath}">'
            layer.open({
                type: 1,//Page层类型
                offset: 'auto',
                area: ['600px', '400px'],
                title: '二维码生成',
                shade: 0.6 ,//遮罩透明度
                maxmin: true ,//允许全屏最小化
                anim: 1 ,//0-6的动画形式，-1不开启
                content: img
            });
        }
    </script>
    <script type="text/javascript">
        function limitUpperLower(upper,lower,opp){
            var real_value=new Number(opp.value.replace(/\b(0+)/gi,""));
            if(real_value>upper){
                real_value=upper;
            }
            if(real_value<lower){
                real_value=lower;
            }
            opp.value=real_value.toString();
            // if(opp.value.length<upper.length)
            // {
            //     var c=upper.length-opp.value.length;
            //     for (let j = 0; j < c; j++) {
            //         opp.value="0"+opp.value;
            //     }
            // }
        }
        function isInputEmpty() {
            var inputlist = document.getElementsByTagName("input");
            for (var i = 0; i < inputlist.length; i++) {
                if (inputlist[i].type == "text" && inputlist[i].value == "") {
                    layer.alert("数字部分不能为空!");
                    return false;
                }
            }
            return true;
        }
    </script>
</head>
<body>
<jsp:include page="../include/head.jsp" />
<jsp:include page="../include/menu.jsp" />
<div id="page-wrapper" style="margin-top: 50px;">
    <div id="page-inner">
        <div class="text-left">
            <a href="/index">首页</a>&nbsp;&gt;&nbsp;<a href="/codeRuleList" class="acts CurrChnlCls">可用编码列表</a>&nbsp;&gt;&nbsp;<a class="acts CurrChnlCls">二维码生成</a>
        </div>
        <div class="row">
            <div class="col-md-12">
                <h3 class="text-left">生成二维码</h3>
            </div>
        </div>
        <hr />
        <br />

        <div class="container-fluid">
            <form  action="/qrCodeResult" class="col-sm-12 select-info table-bordered" method="post" onsubmit="isInputEmpty()">
                <table class="table-bordered">
                    <input type="hidden" id="codeRuleId" value="${enumsum[0].codeRuleId}" name="codeRuleId">
                    <br />
                    <tr>
                        <!------------------------------选择码节点信息--------------------------->
                        <c:set var="j" value="0" />
                        <c:set var="k" value="0" />
                        <c:forEach var="i" begin="1" end="${count}" varStatus="s">
                            <c:choose>
                                <c:when test="${enumsum[j].codeCodeId==i}" >
                                    <div class="col-md-2">
                                        <input type="hidden" name="categoryOptionsDetails" value="${enumsum[j].details}"/>
                                        <label for="categoryOptions${enumsum[j].codeCodeId}" >${enumsum[j].details}</label>
                                    </div>
                                    <div class="col-md-2">
                                        <select id="categoryOptions${enumsum[j].codeCodeId}" class="form-control" role="select" name="categoryOptions">
                                            <script type="text/javascript">
                                                enumDiv("${enumsum[j].detailsNames}","${enumsum[j].basicEnumerations}","categoryOptions${enumsum[j].codeCodeId}");
                                            </script>
                                        </select>
                                    </div>
                                    <c:set var="j" value="${j+1}" />
                                </c:when>
                                <c:otherwise>
                                    <div class="col-md-2">
                                        <label for="categoryOptions${nonenumsum[k].codeCodeId}">${nonenumsum[k].details}</label>
                                        <input type="hidden" name="categoryOptionsDetails" value="${nonenumsum[k].details}"/>
                                    </div>
                                    <div class="col-md-2">
                                        <input  type="number" id="categoryOptions${nonenumsum[k].codeCodeId}"  required="required" class="form-control" name="categoryOptions" value="${nonenumsum[k].lowerLimit}" onchange="limitUpperLower('${nonenumsum[k].upperLimit}','${nonenumsum[k].lowerLimit}',this)" oninput="limitUpperLower('${nonenumsum[k].upperLimit}','${nonenumsum[k].lowerLimit}',this)">
                                        <input type="hidden" id="categoryOptionsLength${nonenumsum[k].upperLimit}" value="${nonenumsum[k].upperLimit}" name="categoryOptionsLength">
                                    </div>
                                    <c:set var="k" value="${k+1}" />
                                </c:otherwise>
                            </c:choose>
                            <c:choose>
                                <c:when test="${i==3}">
                                    <tr><br/><br/></tr>
                                </c:when>
                            </c:choose>
                        </c:forEach>
                    </tr>
                    <br />
                    <br />
                    <div class="col-md-3"></div>
                    <div class="col-md-6">
                        <button  type="submit"  name="confirmm">生成二维码</button>
                    </div>
                    <hr />
                    <br />
                </table>
            </form>

        </div>
    </div>
</div>
</body>
<!-- Javascript -->
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/bootstrap/js/jquery.min.js"></script>
<script src="assets/js/jquery.backstretch.min.js"></script>
</html>
